from TurtleWorld import *
from math import *
 
world=TurtleWorld()
tim = Turtle()
tim.delay=0.01
 
#----------------------------TRIANGLES----------------------------#

def equilateral_tri(t, size=100, rotate=0):
    print "Equilateral Triangle, with Size:", size, "and Rotation:", rotate
    t.lt(rotate)
    count=1
    while count <=3:
        t.fd(size)
        t.lt(120)
        count+=1
    t.rt(rotate)
    
#--------------------------QUADRILATERALS-------------------------#

def para(t, width=100, height=100, angle=120, rotate=0):
    print "Parallelogram, with Width:", width, "Height:", height, "Angle:", angle, "and Rotation:", rotate
    t.lt(rotate)
    count = 1
    while count<=2:
        t.fd(width)
        t.lt(360-angle)
        t.fd(height)
        t.rt(180-angle)
        count+=1
    t.rt(rotate)
    
    

def rhom(t, size=100, angle=120, rotate=0):
    print "Rhombus, with Size:", size, "Angle:", angle, "and Rotation:", rotate
    t.lt(rotate)
    count = 1
    while count<=2:
        t.fd(size)
        t.lt(360-angle)
        t.fd(size)
        t.rt(180-angle)
        count+=1
    t.rt(rotate)
  
def rect(t, width=100, height=100, rotate=0):
    print "Rectangle, with Width:", width, "Height:", height, "and Rotation:", rotate
    t.lt(rotate)
    count=1
    while count <=2:
        t.fd(width)
        t.lt()
        t.fd(height)
        t.lt()
        count+=1
    t.rt(rotate)    
    
def square(t, size=100, rotate=0):
    print "Square, with Size:", size, "and Rotation:", rotate
    t.lt(rotate)
    for side in range(4):
        t.fd(size)
        t.rt(90)
    t.rt(rotate)


def linereturn (t, length=50):
    t.fd(length)
    t.bk(length*2)
    t.fd(length)
    
def sqFlower(t, length=100, pedals=5):
    count = 1
    t.lt(135)
    while count <= pedals:
        square(t, length)
        t.rt(360.0/pedals)
        count+=1

def lineexpand(t, lines=10, angle=100,):
    count = 1
    while count <= lines:
        linereturn(t, count)
        t.rt(angle)
        count+=1

def sqfilled(t, size=20, rotate=0):
    t.lt(rotate)
    count = size
    while count >= 0:
        square(t, count)
        count-=1
    t.rt(rotate)
#------------------------------MOVEMENT---------------------------#

def line(t, x=100, y=100):
    print "Line to a point X:", x, "over and Y:", y, "up"
    dist = sqrt(x**2 + y**2)
    angle = degrees(atan(y/float(x)))
    t.lt(angle)
    t.fd(dist)
    t.rt(angle)
    
    
def move(t, x, y):
    print "Move without marking to a point X:", x, "over and Y:", y, "up"
    t.pu()
    line(t, x, y)
    t.pd()
    
    
    
    
#------------------------------OTHER SHAPES------------------------#
"""
Build any other shape functions you want.
Some Ideas:
    Right Triangles (sss, sas, etc)
    Arbitrary Triangles
    Circle
    Arcs
    Go Wild!
    
Bonus for working or challenging functions...no penalty for trying something
"""

#------------------------------TEST-------------------------------#

equilateral_tri(tim,120,60)
rect(tim,50,90,45)
square(tim,50,20)
para(tim,50, 80,60,5)
line(tim)
move(tim, 30, 20)

wait_for_user()